﻿using System.Collections.Generic;

namespace Gonte.Workflow
{
    /// <summary>
    /// A queue of tasks to be executed
    /// </summary>
    public class TaskProcedure
        : ITask
    {
        #region ITask Members

        public TaskResult Execute(TaskContext context)
        {
            ExceptionThrower.ThrowWhenNull("Tasks", _tasks);

            foreach (ITask task in _tasks)
            {
                task.Execute(context);
            }

            return null;
        }

        #endregion

        /// <summary>
        /// Contains the tasks to be executed
        /// </summary>
        public Queue<ITask> Tasks
        {
            get { return _tasks; }
            set { _tasks = value; }
        }

        private Queue<ITask> _tasks = new Queue<ITask>();
    }
}
